package com.mco.service;

import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.UUID;
import java.util.concurrent.ThreadLocalRandom;


/**
 * @author admin
 */
@Service("redisService")
public class RedisService {


    @Resource
    private RedisTemplate redisTemplate;
    // StringRedisTemplate stringRedisTemplate;

    private static final String PREFIX = "MC-";

    public void insertRedis() {
        int keyId = ThreadLocalRandom.current().nextInt(1000) + 1;
        String serialNo = UUID.randomUUID().toString();

        String key = PREFIX + keyId;
        String value = "随机演示" + serialNo;
        redisTemplate.opsForValue().set(key, value);
        System.out.println(redisTemplate.opsForValue().get(key));
//        stringRedisTemplate.opsForValue().set(key, value);
//        System.out.println(stringRedisTemplate.opsForValue().get(key));

    }
}
